#pragma once
#include "HashTable.h"

namespace bit
{
	template<class K,class V,class Hash = HashFunc<K>>
	class map
	{
		struct mapKeyofv {
			const K& operator()(const pair<K, V>& kv)
			{
				return kv.first;
			}
		};
		typedef HashBucket::HashTable<K, pair<K, V>, mapKeyofv, Hash> HT;
	public:
		typedef typename HT::Iterator Iterator;
		Iterator begin()
		{
			return _ht.begin();
		}

		Iterator end()
		{
			return _ht.end();
		}

		pair<Iterator, bool> Insert(const pair<K, V>& kv)
		{
			return _ht.Insert(kv);
		}

		V& operator[](const K& key)
		{
			pair<Iterator, bool> ret = _ht.Insert(make_pair(key, V()));
			return ret.first->second;
		}
	private:
		HT _ht;
	};


}